<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-28 09:54:07
 * @LastEditors: Please set LastEditors
 * @Description: 服务器操作历史
 * @FilePath: /special/application/adminapiv3/service/platform_manage/log/ServerOptionHistoryService.php
 */
namespace app\adminapiv3\service\platform_manage\log;




use app\adminapiv3\service\BaseService;
use app\common\service\platform_manage\ServerAuthService;

class ServerOptionHistoryService extends BaseService
{
    public function list($params)
    {
        $server = new \app\common\service\platform_manage\log\ServerOptionHistoryService();
        $list = $server->list($params);

        foreach($list['data'] as $k => $v){
            $v['ctime'] = date('Y-m-d H:i:s', $v['ctime']);
            $list['data'][$k] = $v;
        }

        return $list;
    }


    public function indexData()
    {
        //1. 查询模块
        $moduleServer = new ServerAuthService();
        $module = $moduleServer->findAll('id, product_name as name');

        $data['module_name'] = $module;

        return $data;
    }

    /**
     * @name 日志详情
     * @param $id
     * @author wx
     * @date 2020/10/26 10:33
     */
    public function detail($id)
    {
        $server = new \app\common\service\platform_manage\log\ServerOptionHistoryService();

        $field = 'id, is_detail, content, old_info, new_info';

        $info = $server->findData(['id' => $id], $field);

        if (!$info) {
            $this->setError($this->CODE_FAIL, '该条日志不存在');
            return false;
        }

        if ($info['is_detail'] != 1) {
            $this->setError($this->CODE_FAIL, '该条日志暂无详情');
            return false;
        }

        return $info;
    }
}